<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>备料导入</title>
</head>
<body>
<style>
    .essence_upload_div{
        width: 200px;
        height: 50px;
        margin: 30px auto;
    }
    .essence_upload_div button,.essence_upload_div input{
        width: 150px;
        height: 30px;
    }

    .essence_upload_div a{
        text-decoration: none;
    }
</style>

    <div class="essence_upload_div">

        <button id="essence_download_button"><a href="/essence/downloadTemplate">下载备料excel模版</a></button>

    </div>
    <div class="essence_upload_div">
        <form id="essence_upload_form" action="/essence/upload" method="post" enctype="multipart/form-data">
            <input type="file" name="filename" id="filename"/>
        </form>
        <button id="essence_upload_button" >上传备料excel文件</button>
    </div>

<script>

    $("#essence_upload_button").click(function () {
        var formData = new FormData($("#essence_upload_form")[0]);
        $.ajax({
            url: "/essence/upload",
            type: "POST",
            data: formData,
            cache: false,    //上传文件不需缓存
            contentType: false,
            processData: false,
            dataType:'json',
            success: function (data) {
                windowsOperation(null,null,data);
            },
            error: function () {
                alert("上传失败！");
            }
        });
    });

</script>
</body>
</html>